#ifndef CL_News_H_INCLUDED
#define CL_News_H_INCLUDED

#include<string>
#include<map>
#include<time.h>
#include "unicode/unistr.h"
#include "pugixml.hpp"

extern const char* progname;

typedef std::string ustring;
typedef std::string language_code;
typedef std::string guidstring;

struct CL_channel {
     ustring titel;
     std::string url;
     ustring description;
     language_code language;
     ustring copyright;
     time_t pubDate;
     struct image {
          std::string url;
          ustring titel;
          std::string link;
          image():url(""),titel(""),link("") {};
     };
     image img;
     CL_channel():titel(""),url(""),description(""),language(""),copyright(""),pubDate(0),img() {};
     CL_channel(const std::string s):titel("Program warning"), url("http://code.google.com/p/mk2366-rss-reader/"),
     description("No news found in internet"), copyright(""), pubDate(time(NULL)), img(){};
};
struct CL_newsitem {
     ustring title;
     ustring description;
     std::string link;
     ustring author;
     time_t pubDate;
     CL_newsitem():title(""),description(""),link(""),author(""),pubDate(0) {};
     CL_newsitem(const std::string s):title("Hoppla"),description(s),link("http://code.google.com/p/mk2366-rss-reader/"),
     author("Markus Kupke"), pubDate(time(NULL)){};
     void clear(){title.clear(); description.clear(); link.clear(); author.clear(); pubDate=0;};
};

class CL_News {
public:
     CL_News():channel(),newsitem(){};
     CL_News(const std::string s):channel(s),newsitem(s){};
     CL_channel channel;
     CL_newsitem newsitem;
};

struct key_pair {
     time_t t;
     std::size_t guid;
     bool operator<(const key_pair& kp) const {
          if(kp.t==t)return bool(guid<kp.guid);
          return bool(t<kp.t);
     };
     key_pair():t(0),guid(0) {};
     struct comp {
          bool operator()(const key_pair& k1, const key_pair& k2) {
               return bool(k1<k2);
          };
     };
     void clear(){t=0; guid=0;};
};

typedef std::map<key_pair, CL_News, key_pair::comp> newsmap;

#endif // CL_News_H_INCLUDED
